function adminContent(url, data) {
	var cont = $("#container");
	$.ajax({
		url: url,
		data: data,
		type: "post",
		beforeSend: function() {
			cont.html("&nbsp;&nbsp;&nbsp;&nbsp;loading...");
			cont.addClass("loading");
		},
		complete: function(req) {
			cont.removeClass("loading");
			if(req.status==200) {
				cont.html(req.responseText);
			}else{
				cont.html(req.status + ". " + req.statusText);
			}
		}
	});
}

function Translate(lang, entity, id) {
	var div = $("#translation-container");
	if(!div.length) {
		div = $('<div id="translation-container" />');
	}
	
	if(!confirm("Da li ste sačuvali izmene?\n\n Ako niste kliknite na \"Cancel\" pa na \"Sačuvaj\".")) {
		return;
	}
	
	div.dialog({
		width: 800,
		height: 600,
		title: "Prevod: "+languages[lang],
		beforeclose: function(e) {
			location.reload();
			div.dialog("destroy");
		}
	});
	$.ajax({
		url: root + "/translate/"+entity+"/"+id+"/"+lang,
		beforeSend: function() {
			div.html("molim sačekajte...");
		},
		complete: function(req) {
			div.html(req.responseText);
		}
	});
}
function TranslateSend(form, entity, id, lang) {
	var data = {};
	var sbmt = $(form).find("input[type=submit]");
	
	$(form).find("*[name]").each(function(){
		switch(this.type) {
			default:
				data[this.name] = typeof(ckeditors[this.id])=="undefined"?this.value:ckeditors[this.id].getData();
				break;
		}
	});
	$.ajax({
		url: root + "/translate/"+entity+"/"+id+"/"+lang,
		type: "post",
		data: data,
		beforeSend: function() {
			sbmt.val("Molim sačekajte...");
			sbmt.attr("disabled", true);
		},
		complete: function(req) {
			sbmt.attr("disabled", false);
			sbmt.val("Sačuvaj");
			if(req.status == 200) {
				var status = parseInt(req.getResponseHeader("X-Translate-Status"));
				if(status) {
					alert("Prevod je sačuvan");
					$("#translation-container").dialog("destroy");
					location.reload();
				}else{
					alert(req.responseText)
				}
			}
		}
	})
}

function ShowTab(link, expr) {
	$(".tab-content").hide();
	$(expr).show();
	
	var parentLI = $(link).parent();
	var li = parentLI.parent().find("li");
	
	li.removeClass("active");
	parentLI.addClass("active");
	
}